import java.util.Scanner;
public class test1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter the first 9 digits of an ISBN as integer: ");
        int isbn9 = scanner.nextInt(); 
        int d9 = isbn9 % 10;
        int temp = isbn9 / 10;
        int d8 = temp % 10;
        temp /= 10;
        int d7 = temp % 10;
        temp /= 10;
        int d6 = temp % 10;
        temp /= 10;
        int d5 = temp % 10;
        temp /= 10;
        int d4 = temp % 10;
        temp /= 10;
        int d3 = temp % 10;
        temp /= 10;
        int d2 = temp % 10;
        temp /= 10;
        int d1 = temp % 10;
        int checksum = (d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 
                      + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11;
        String isbn10;
        if (checksum == 10) {
            isbn10 = String.format("%09dX", isbn9); 
        } else {
            isbn10 = String.format("%09d%d", isbn9, checksum); 
        }
        System.out.println("The ISBN-10 number is " + isbn10);
        scanner.close();
    }
}
